package com.opgea.crm.domain.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.opgea.crm.domain.entities.security.CrmUser;

@Entity
@Table(name="additionalcontact")
public class AdditionalContact implements Serializable {

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="id")
	private Long id;
	@Column(name="firstname")
	private String firstName;
	@Column(name="middleinitial")
	private String middleInitial;
	@Column(name="lastname")
	private String lastName;
	@Column(name="email")
	private String email;
	@Column(name="workphone")
	private String workPhone;
	@Column(name="homephone")
	private String homePhone;
	@Column(name="mobileno")
	private String mobileNo;
	@Column(name="fax")
	private String fax;
	@Column(name="title")
	private String title;
	
	@JoinColumn(name = "lead_id", referencedColumnName = "id")
	@ManyToOne
	private Lead lead;
	
	@OneToMany(mappedBy="contactTo", cascade=CascadeType.ALL)
	private List<ProjectDetails> projects;
	
	@ManyToOne(cascade=CascadeType.REFRESH)
	@JoinColumn(name="createdBy", referencedColumnName="username")
	private CrmUser createdBy;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="createdat")
	private Date createdAt;

	
	public AdditionalContact() {
		super();
		
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getMiddleInitial() {
		return middleInitial;
	}
	public void setMiddleInitial(String middleInitial) {
		this.middleInitial = middleInitial;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getWorkPhone() {
		return workPhone;
	}
	public void setWorkPhone(String workPhone) {
		this.workPhone = workPhone;
	}
	public String getHomePhone() {
		return homePhone;
	}
	public void setHomePhone(String homePhone) {
		this.homePhone = homePhone;
	}
	public String getMobileNo() {
		return mobileNo;
	}
	public void setMobileNo(String mobileNo) {
		this.mobileNo = mobileNo;
	}
	public String getFax() {
		return fax;
	}
	public void setFax(String fax) {
		this.fax = fax;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public void setLead(Lead lead) {
		this.lead = lead;
	}
	public Lead getLead() {
		return lead;
	}
	public void setProjects(List<ProjectDetails> projects) {
		this.projects = projects;
	}
	public List<ProjectDetails> getProjects() {
		return projects;
	}
	public void setCreatedBy(CrmUser createdBy) {
		this.createdBy = createdBy;
	}
	public CrmUser getCreatedBy() {
		return createdBy;
	}
	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}
	public Date getCreatedAt() {
		return createdAt;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AdditionalContact other = (AdditionalContact) obj;
		if (id != other.id)
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "AdditionalContact [email=" + email + ", fax=" + fax
				+ ", firstName=" + firstName + ", homePhone=" + homePhone
				+ ", id=" + id + ", lastName=" + lastName + ", lead=" + lead
				+ ", middleInitial=" + middleInitial + ", mobileNo=" + mobileNo
				+ ", projects=" + projects + ", title=" + title
				+ ", workPhone=" + workPhone + "]";
	}
	
	
}
